﻿@page "/"
@using System.Globalization
@inject NavigationManager NavigationManager

<h1>欢迎来到主页</h1>
<RadzenStack Orientation="Orientation.Vertical">
    <RadzenStack Orientation="Orientation.Horizontal" Style="width:100%">
        <RadzenCardGroup>
            <RadzenCard Style="height:100px; background-color:blue;">

            </RadzenCard>
            <RadzenCard Style="height:100px;width:500px; background-color:antiquewhite;">

            </RadzenCard>
            <RadzenCard Style="width: 100px; background-color:aquamarine;">

            </RadzenCard>
            <RadzenCard Style="width: 100px; background-color: blueviolet;">                

            </RadzenCard>
            <RadzenCard Style="width: 100px; background-color: bisque">                

            </RadzenCard>
            <RadzenCard Style="width: 100px; background-color:aqua;">                

            </RadzenCard>
        </RadzenCardGroup>
    </RadzenStack>
    <RadzenStack Style="height:900px">
        <RadzenChart>
            <RadzenChartTooltipOptions Shared="@sharedTooltip" />
            <RadzenLineSeries Smooth="@smooth" Data="@revenue2023" CategoryProperty="Date" Title="2023" LineType="LineType.Dashed" ValueProperty="Revenue">
                <RadzenMarkers Visible="@showMarkers" MarkerType="MarkerType.Square" />
                <RadzenSeriesDataLabels Visible="@showDataLabels" />
            </RadzenLineSeries>
            <RadzenLineSeries Smooth="@smooth" Data="@revenue2024" CategoryProperty="Date" Title="2024" ValueProperty="Revenue">
                <RadzenMarkers Visible="@showMarkers" MarkerType="MarkerType.Circle" />
                <RadzenSeriesDataLabels Visible="@showDataLabels" />
            </RadzenLineSeries>
            <RadzenCategoryAxis Padding="20" />
            <RadzenValueAxis Formatter="@FormatAsUSD">
                <RadzenGridLines Visible="true" />
                <RadzenAxisTitle Text="Revenue in USD" />
            </RadzenValueAxis>
        </RadzenChart>
    </RadzenStack>

</RadzenStack>
@code {
    int value = 1;
    bool smooth = false;
    bool sharedTooltip = true;
    bool showDataLabels = false;
    bool showMarkers = true;

    class DataItem
    {
        public string Date { get; set; }
        public double Revenue { get; set; }
    }

    string FormatAsUSD(object value)
    {
        return ((double)value).ToString("C0", CultureInfo.CreateSpecificCulture("zh-CN"));
    }

    DataItem[] revenue2023 = new DataItem[] {
        new DataItem
        {
            Date = "Jan",
            Revenue = 234000
        },
        new DataItem
        {
            Date = "Feb",
            Revenue = 269000
        },
        new DataItem
        {
            Date = "Mar",
            Revenue = 233000
        },
        new DataItem
        {
            Date = "Apr",
            Revenue = 244000
        },
        new DataItem
        {
            Date = "May",
            Revenue = 214000
        },
        new DataItem
        {
            Date = "Jun",
            Revenue = 253000
        },
        new DataItem
        {
            Date = "Jul",
            Revenue = 274000
        },
        new DataItem
        {
            Date = "Aug",
            Revenue = 284000
        },
        new DataItem
        {
            Date = "Sept",
            Revenue = 273000
        },
        new DataItem
        {
            Date = "Oct",
            Revenue = 282000
        },
        new DataItem
        {
            Date = "Nov",
            Revenue = 289000
        },
        new DataItem
        {
            Date = "Dec",
            Revenue = 294000
        }
    };

    DataItem[] revenue2024 = new DataItem[] {
        new DataItem
        {
            Date = "Jan",
            Revenue = 334000
        },
        new DataItem
        {
            Date = "Feb",
            Revenue = 369000
        },
        new DataItem
        {
            Date = "Mar",
            Revenue = 333000
        },
        new DataItem
        {
            Date = "Apr",
            Revenue = 344000
        },
        new DataItem
        {
            Date = "May",
            Revenue = 314000
        },
        new DataItem
        {
            Date = "Jun",
            Revenue = 353000
        },
        new DataItem
        {
            Date = "Jul",
            Revenue = 374000
        },
        new DataItem
        {
            Date = "Aug",
            Revenue = 384000
        },
        new DataItem
        {
            Date = "Sept",
            Revenue = 373000
        },
        new DataItem
        {
            Date = "Oct",
            Revenue = 382000
        },
        new DataItem
        {
            Date = "Nov",
            Revenue = 389000
        },
        new DataItem
        {
            Date = "Dec",
            Revenue = 394000
        }
    };

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        if (AppSession.User == null)
        {
            // 未登录用户重定向到登录页，并携带返回URL
            NavigationManager.NavigateTo($"/login", true);
        }
    }
}
